package com.lmiot.xyclick.Activity;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.Gson;
import com.lmiot.xyclick.App.MyApp;
import com.lmiot.xyclick.KeYi.ChangeVIPData;
import com.lmiot.xyclick.KeYi.HttpUtilXYPro;
import com.lmiot.xyclick.KeYi.SuggListBeanRes;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.HttpUtilNew;
import com.lmiot.xyclick.Util.LayoutDialogUtil;
import com.lmiot.xyclick.Util.PhoneUtil;
import com.lmiot.xyclick.inteface.OnBasicListener;
import com.youyi.yychosesdk.SDK.YYChoseSDK;
import com.youyi.yychosesdk.models.album.entity.Photo;
import com.youyi.yypermissionlibrary.SDK.OnPerListener;
import com.youyi.yypermissionlibrary.SDK.YYPerUtils;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import com.youyi.yyviewsdklibrary.LoadingDialog;
import com.youyi.yyviewsdklibrary.View.MyEditView;
import com.youyi.yyviewsdklibrary.View.MyListView;
import com.youyi.yyviewsdklibrary.View.TitleBarView;
import com.youyi.yyviewsdklibrary.YYSDK;
import java.util.ArrayList;
import java.util.List;

public class OldPayVIPActivity extends BaseActivity implements View.OnClickListener {
    TextView mBtStart;
    MyEditView mIdEmial;
    ImageView mIdImg;
    MyListView mIdListview;
    MyEditView mIdOldUserId;
    LinearLayout mIdTipLayout;
    TextView mIdTipMsg;
    TitleBarView mIdTitleBar;
    private String mImagePath;

    /* access modifiers changed from: protected */
    @Override // android.support.v4.app.SupportActivity, com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_pay_old);
        initView();
        this.mIdTitleBar.setOnItemClickListener(new TitleBarView.onItemClickListener() {
            /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass1 */

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onTitleClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onBackClick(View view) {
                OldPayVIPActivity.this.finish();
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onMenuClick(View view) {
                OldPayVIPActivity.this.showListView();
            }
        });
        YYPerUtils.sd(new OnPerListener() {
            /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass2 */

            @Override // com.youyi.yypermissionlibrary.SDK.OnPerListener
            public void result(boolean z, String str) {
                if (z) {
                    final String oldVIPID = PhoneUtil.getOldVIPID(MyApp.getContext());
                    HttpUtilNew.getInstance().checkVIP(oldVIPID, new OnBasicListener() {
                        /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass2.AnonymousClass1 */

                        @Override // com.lmiot.xyclick.inteface.OnBasicListener
                        public void result(boolean z, String str) {
                            if (z) {
                                OldPayVIPActivity.this.requesVIPDialog(oldVIPID);
                            }
                            OldPayVIPActivity.this.mIdOldUserId.setText(oldVIPID);
                            OldPayVIPActivity.this.showListView();
                        }
                    });
                    return;
                }
                OldPayVIPActivity.this.finish();
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void requesVIPDialog(final String str) {
        LayoutDialogUtil.showSureDialog(this, "温馨提示", "系统检测到本设备已开通过会员，\n您是否要进行微信绑定并免费申请永久会员？", true, true, "取消", "确定申请", new LayoutDialogUtil.OnResultClickListener() {
            /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass3 */

            @Override // com.lmiot.xyclick.Util.LayoutDialogUtil.OnResultClickListener
            public void result(boolean z) {
                if (z) {
                    HttpUtilXYPro.getInstance().addSuggesion(str, "vipold/icon_small.png", "该设备已经是会员", new OnBasicListener() {
                        /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass3.AnonymousClass1 */

                        @Override // com.lmiot.xyclick.inteface.OnBasicListener
                        public void result(boolean z, String str) {
                            LoadingDialog.hidden();
                            if (z) {
                                ToastUtil.success("申请成功，已经通知管理员进行审核，请勿重新提交！");
                                OldPayVIPActivity.this.showListView();
                                return;
                            }
                            ToastUtil.err("申请失败,请检查网络或联系管理员！");
                        }
                    });
                }
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showListView() {
        LoadingDialog.show(this, LoadingDialog.DialogType.CENTER, true, "");
        HttpUtilXYPro.getInstance().suggestionList(new HttpUtilXYPro.OnSuggeListResult() {
            /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass4 */

            @Override // com.lmiot.xyclick.KeYi.HttpUtilXYPro.OnSuggeListResult
            public void result(boolean z, String str, List<SuggListBeanRes.DataBean> list) {
                LoadingDialog.hidden();
                if (z) {
                    OldPayVIPActivity.this.mIdListview.setAdapter((ListAdapter) new MyAdapter(list));
                }
            }
        });
    }

    private void initView() {
        this.mIdTitleBar = (TitleBarView) findViewById(R.id.id_title_bar);
        this.mIdTipMsg = (TextView) findViewById(R.id.id_tip_msg);
        this.mIdTipLayout = (LinearLayout) findViewById(R.id.id_tip_layout);
        this.mIdOldUserId = (MyEditView) findViewById(R.id.id_old_user_id);
        this.mIdImg = (ImageView) findViewById(R.id.id_img);
        this.mIdEmial = (MyEditView) findViewById(R.id.id_emial);
        this.mIdListview = (MyListView) findViewById(R.id.id_listview);
        this.mBtStart = (TextView) findViewById(R.id.bt_start);
        this.mIdImg.setOnClickListener(this);
        this.mBtStart.setOnClickListener(this);
    }

    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.bt_start) {
            final String text = this.mIdOldUserId.getText();
            if (TextUtils.isEmpty(text)) {
                ToastUtil.err("旧会员不能为空！");
            } else if (TextUtils.isEmpty(this.mImagePath)) {
                ToastUtil.err("付款截图不能为空！");
            } else {
                final String text2 = this.mIdEmial.getText();
                if (TextUtils.isEmpty(text2)) {
                    ToastUtil.err("接收邮件不能为空！");
                    return;
                }
                LoadingDialog.show(this, LoadingDialog.DialogType.CENTER, true, "请稍候……");
                HttpUtilXYPro.getInstance().uploadImg(text, this.mImagePath, text2, new OnBasicListener() {
                    /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass6 */

                    @Override // com.lmiot.xyclick.inteface.OnBasicListener
                    public void result(boolean z, String str) {
                        if (z) {
                            HttpUtilXYPro.getInstance().addSuggesion(text, str, text2, new OnBasicListener() {
                                /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass6.AnonymousClass1 */

                                @Override // com.lmiot.xyclick.inteface.OnBasicListener
                                public void result(boolean z, String str) {
                                    LoadingDialog.hidden();
                                    if (z) {
                                        ToastUtil.success("申请成功，已经通知管理员进行审核，请勿重新提交！");
                                        OldPayVIPActivity.this.showListView();
                                        return;
                                    }
                                    ToastUtil.err("申请失败,请检查网络或联系管理员！");
                                }
                            });
                            return;
                        }
                        LoadingDialog.hidden();
                        ToastUtil.err("申请失败,请检查网络或联系管理员！");
                    }
                });
            }
        } else if (id == R.id.id_img) {
            YYChoseSDK.getInstance(this).chosePic(false, 1, new YYChoseSDK.OnSelectListener() {
                /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.AnonymousClass5 */

                @Override // com.youyi.yychosesdk.SDK.YYChoseSDK.OnSelectListener
                public void onCancel() {
                }

                @Override // com.youyi.yychosesdk.SDK.YYChoseSDK.OnSelectListener
                public void onResult(ArrayList<Photo> arrayList, boolean z) {
                    OldPayVIPActivity.this.mImagePath = arrayList.get(0).path;
                    Glide.with((FragmentActivity) OldPayVIPActivity.this).load(OldPayVIPActivity.this.mImagePath).into(OldPayVIPActivity.this.mIdImg);
                }
            });
        }
    }

    private class MyAdapter extends BaseAdapter {
        private List<SuggListBeanRes.DataBean> mList;

        public Object getItem(int i) {
            return null;
        }

        public long getItemId(int i) {
            return 0;
        }

        public MyAdapter(List<SuggListBeanRes.DataBean> list) {
            this.mList = list;
        }

        public int getCount() {
            return this.mList.size();
        }

        public View getView(int i, View view, ViewGroup viewGroup) {
            View inflate = View.inflate(OldPayVIPActivity.this, R.layout.item_suggess, null);
            final ImageView imageView = (ImageView) inflate.findViewById(R.id.id_img);
            TextView textView = (TextView) inflate.findViewById(R.id.id_name_old);
            TextView textView2 = (TextView) inflate.findViewById(R.id.id_name_new);
            TextView textView3 = (TextView) inflate.findViewById(R.id.id_detail);
            ImageView imageView2 = (ImageView) inflate.findViewById(R.id.id_result);
            TextView textView4 = (TextView) inflate.findViewById(R.id.id_result_text);
            SuggListBeanRes.DataBean dataBean = this.mList.get(i);
            try {
                ChangeVIPData changeVIPData = (ChangeVIPData) new Gson().fromJson(dataBean.getSuggestion_name(), ChangeVIPData.class);
                int suggestion_check_state = dataBean.getSuggestion_check_state();
                if (suggestion_check_state == 1) {
                    Glide.with((FragmentActivity) OldPayVIPActivity.this).load(Integer.valueOf((int) R.drawable.sg_success)).into(imageView2);
                    textView4.setText("审核通过");
                    textView4.setTextColor(OldPayVIPActivity.this.getResources().getColor(R.color.successColor));
                } else if (suggestion_check_state == 2) {
                    textView4.setText("审核不通过，旧ID非会员！");
                    textView4.setTextColor(OldPayVIPActivity.this.getResources().getColor(R.color.errorColor));
                    Glide.with((FragmentActivity) OldPayVIPActivity.this).load(Integer.valueOf((int) R.drawable.sg_error)).into(imageView2);
                } else if (suggestion_check_state != 3) {
                    Glide.with((FragmentActivity) OldPayVIPActivity.this).load(Integer.valueOf((int) R.drawable.sg_ing)).into(imageView2);
                    textView4.setText("审核中，请稍候……");
                    textView4.setTextColor(OldPayVIPActivity.this.getResources().getColor(R.color.warningColor));
                } else {
                    textView4.setText("审核不通过，付款截图不对！");
                    textView4.setTextColor(OldPayVIPActivity.this.getResources().getColor(R.color.errorColor));
                    Glide.with((FragmentActivity) OldPayVIPActivity.this).load(Integer.valueOf((int) R.drawable.sg_error)).into(imageView2);
                }
                textView.setText("旧ID：" + changeVIPData.getOldID());
                textView2.setText("新ID：" + changeVIPData.getNewID());
                textView3.setText(dataBean.getSuggestion_time());
                final String str = "https://www.youyikeji.tech/images/changevip/" + changeVIPData.getImg();
                Glide.with(MyApp.getContext()).load(str).apply(new RequestOptions().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).fitCenter()).into(imageView);
                imageView.setOnClickListener(new View.OnClickListener() {
                    /* class com.lmiot.xyclick.Activity.OldPayVIPActivity.MyAdapter.AnonymousClass1 */

                    public void onClick(View view) {
                        YYSDK.getInstance().showBigImg(OldPayVIPActivity.this, imageView, str, false);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
            return inflate;
        }
    }
}
